package com.ripplezjw.blog.controller;

import com.ripplezjw.blog.Service.ArticleService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import java.text.ParseException;

@Controller
public class TimeController {
    @Autowired
    ArticleService articleService;

    @GetMapping("/createTime/{time}")
    public String cTimeList(@PathVariable("time") String time,
                           Model model) throws ParseException {
//        System.out.println(time);
        model.addAttribute("articles", articleService.findArticleByTime(time));
        return "articleList";
    }

    @GetMapping("/modTime/{time}")
    public String mTimeList(@PathVariable("time") String time,
                           Model model) throws ParseException {

        model.addAttribute("articles", articleService.findArticleByModTime(time));
        return "articleList";
    }
}
